﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Traceability.App.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class UploadController : ControllerBase
    {
        private readonly IWebHostEnvironment web;

        public UploadController(IWebHostEnvironment web)
        {
            this.web = web;
        }

        [HttpPost]
        public IActionResult uploa(IFormFile file)
        {
            string path=web.WebRootPath+@"/img/"+file.FileName;
            using (FileStream fs=System.IO.File.Create(path))
            {
                file.CopyTo(fs);
                fs.Close();
            }
            return Ok("http://localhost:5199/img/"+file.FileName);
        }


    }
}
